﻿Imports System.Windows.Forms

Namespace Settings
    Public Class Provider
        Private Shared mProvider As IProvider
        Private Shared mTabs As New Generic.Dictionary(Of String, System.Type)

        Public Interface IProvider
            Sub Show(ByVal owner As IWin32Window)
            Function ShowDialog(ByVal owner As IWin32Window, ByVal tabKeys() As String) As Boolean
        End Interface

        Public Shared Function GetAllRegisteredTabs() As Generic.Dictionary(Of String, System.Type)
            Return mTabs
        End Function

        Public Shared Sub RegisterProvider(ByVal provider As IProvider)
            mProvider = provider
        End Sub

        Public Shared Sub RegisterTab(ByVal key As String, ByVal type As System.Type)
            mTabs.Add(key, type)
        End Sub

        Public Shared Sub Show(ByVal owner As IWin32Window)
            mProvider.Show(owner)
        End Sub
        Public Shared Function ShowDialog(ByVal owner As IWin32Window, ByVal tabKeys() As String) As Boolean
            Return mProvider.ShowDialog(owner, tabKeys)
        End Function
        Public Shared Function ShowDialog(ByVal owner As IWin32Window, ByVal tabKey As String) As Boolean
            Return mProvider.ShowDialog(owner, New String() {tabKey})
        End Function

    End Class
End Namespace